﻿outremer_elective_ai = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	}
	ai_goal = yes
	is_shown = {
		is_ai = yes
	}
	is_valid = {
		is_ai = yes
		OR = {
			government_has_flag = government_is_feudal
			government_has_flag = government_is_theocracy
		}
		has_faith = faith:catholic
		OR = {
			highest_held_title_tier >= tier_kingdom
			AND = {
				highest_held_title_tier = 3
				is_independent_ruler = yes
			}
		}
		can_change_title_law_trigger = yes
		OR = {
			culture = {
				has_cultural_parameter = outremer_elective_succession_enabled
			}
			any_held_title = {
				tier = 3
				title_capital_county.title_province = {
					geographical_region = world_middle_east
				}
			}
		}
		NOT = {
			primary_title = {
				has_title_law = outremer_elective_succession_law
			}
		}
		any_held_title = {
			NOR = {
				has_title_law = gaelic_elective_succession_law
				has_title_law = imperial_elective_succession_law
				has_title_law = scandinavian_elective_succession_law
				has_title_law = eldership_elective_succession_law
				has_title_law = princely_elective_succession_law
				has_title_law = feudal_elective_succession_law
				has_title_law = saxon_elective_succession_law
				has_title_law = mahestan_elective_succession_law
				has_title_law = royal_elective_succession_law
				has_title_law = kurultai_elective_succession_law
			}
		}
	}
	effect = {
		every_held_title = {
			limit = { has_title_law = outremer_elective_succession_law }
			clear_title_laws = yes
		}
		primary_title = {
			add_title_law = outremer_elective_succession_law
		}
	}
	ai_will_do = 100
}
saxon_elective_ai = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	}
	ai_goal = yes
	is_shown = {
		is_ai = yes
	}
	is_valid = {
		is_ai = yes
		OR = {
			government_has_flag = government_is_feudal
			government_has_flag = government_is_tribal
		}
		OR = {
			highest_held_title_tier >= tier_kingdom
			AND = {
				highest_held_title_tier = 3
				is_independent_ruler = yes
			}
		}
		can_change_title_law_trigger = yes
		culture = { 
			has_cultural_parameter = witenagemot_succession_enabled 
			has_cultural_pillar = heritage_west_germanic
		}
		NOT = {
			primary_title = {
				has_title_law = saxon_elective_succession_law
			}
		}
		any_held_title = {
			NOR = {
				has_title_law = gaelic_elective_succession_law
				has_title_law = imperial_elective_succession_law
				has_title_law = scandinavian_elective_succession_law
				has_title_law = eldership_elective_succession_law
				has_title_law = princely_elective_succession_law
				has_title_law = feudal_elective_succession_law
				has_title_law = outremer_elective_succession_law
				has_title_law = mahestan_elective_succession_law
				has_title_law = royal_elective_succession_law
				has_title_law = kurultai_elective_succession_law
			}
		}
	}
	effect = {
		every_held_title = {
			limit = { has_title_law = saxon_elective_succession_law }
			clear_title_laws = yes
		}
		primary_title = {
			add_title_law = saxon_elective_succession_law
		}
	}
	ai_will_do = 100
}
scandinavian_elective_ai = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	}
	ai_goal = yes
	is_shown = {
		is_ai = yes
	}
	is_valid = {
		is_ai = yes
		OR = {
			government_has_flag = government_is_feudal
			government_has_flag = government_is_tribal
		}
		OR = {
			highest_held_title_tier >= tier_kingdom
			AND = {
				highest_held_title_tier = 3
				is_independent_ruler = yes
			}
		}
		can_change_title_law_trigger = yes
		culture = { 
			has_cultural_parameter = scandinavian_elective_enabled 
			has_cultural_pillar = heritage_north_germanic
		}
		NOT = {
			primary_title = {
				has_title_law = scandinavian_elective_succession_law
			}
		}
		any_held_title = {
			NOR = {
				has_title_law = saxon_elective_succession_law
				has_title_law = gaelic_elective_succession_law
				has_title_law = imperial_elective_succession_law
				has_title_law = eldership_elective_succession_law
				has_title_law = princely_elective_succession_law
				has_title_law = feudal_elective_succession_law
				has_title_law = outremer_elective_succession_law
				has_title_law = mahestan_elective_succession_law
				has_title_law = royal_elective_succession_law
				has_title_law = kurultai_elective_succession_law
			}
		}
	}
	effect = {
		every_held_title = {
			limit = {
				has_title_law = scandinavian_elective_succession_law 
			}
			clear_title_laws = yes
		}
		primary_title = {
			add_title_law = scandinavian_elective_succession_law
		}
	}
	ai_will_do = 100
}
gaelic_elective_ai = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	}
	ai_goal = yes
	is_shown = {
		is_ai = yes
	}
	is_valid = {
		is_ai = yes
		OR = {
			government_has_flag = government_is_feudal
			government_has_flag = government_is_tribal
		}
		highest_held_title_tier >= tier_duchy
		can_change_title_law_trigger = yes
		OR = {
			has_culture = culture:irish
			AND = {
				has_culture = culture:gaelic
				current_date < 1050.1.1
			}
		}
		NOT = {
			primary_title = {
				has_title_law = gaelic_elective_succession_law
			}
		}
		any_held_title = {
			NOR = {
				has_title_law = saxon_elective_succession_law
				has_title_law = imperial_elective_succession_law
				has_title_law = scandinavian_elective_succession_law
				has_title_law = eldership_elective_succession_law
				has_title_law = princely_elective_succession_law
				has_title_law = feudal_elective_succession_law
				has_title_law = outremer_elective_succession_law
				has_title_law = mahestan_elective_succession_law
				has_title_law = royal_elective_succession_law
				has_title_law = kurultai_elective_succession_law
			}
		}
	}
	effect = {
		every_held_title = {
			limit = { has_title_law = gaelic_elective_succession_law }
			clear_title_laws = yes
		}
		primary_title = {
			add_title_law = gaelic_elective_succession_law
		}
	}
	ai_will_do = 100
}
eldership_elective_ai = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	}
	ai_goal = yes
	is_shown = {
		is_ai = yes
	}
	is_valid = {
		is_ai = yes
		OR = {
			government_has_flag = government_is_feudal
			government_has_flag = government_is_tribal
		}
		OR = {
			this.religion = religion:baltic_religion
			this.religion = religion:west_african_religion
			this.religion = religion:akom_religion
			this.religion = religion:west_african_roog_religion
			this.religion = religion:west_african_orisha_religion
		}
		highest_held_title_tier >= tier_duchy
		can_change_title_law_trigger = yes
		faith = {
			has_doctrine = tenet_ancestor_worship
		}
		NOT = {
			primary_title = {
				has_title_law = eldership_elective_succession_law
			}
		}
		any_held_title = {
			NOR = {
				has_title_law = saxon_elective_succession_law
				has_title_law = gaelic_elective_succession_law
				has_title_law = imperial_elective_succession_law
				has_title_law = scandinavian_elective_succession_law
				has_title_law = princely_elective_succession_law
				has_title_law = feudal_elective_succession_law
				has_title_law = outremer_elective_succession_law
				has_title_law = mahestan_elective_succession_law
				has_title_law = royal_elective_succession_law
				has_title_law = kurultai_elective_succession_law
			}
		}
	}
	effect = {
		every_held_title = {
			limit = { has_title_law = eldership_elective_succession_law }
			clear_title_laws = yes
		}
		primary_title = {
			add_title_law = eldership_elective_succession_law
		}
	}
	ai_will_do = 100
}
mahestan_elective_ai = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	}
	ai_goal = yes
	is_shown = {
		is_ai = yes
	}
	is_valid = {
		is_ai = yes
		OR = {
			government_has_flag = government_is_feudal
		}
		highest_held_title_tier >= tier_kingdom
		is_independent_ruler = yes
		can_change_title_law_trigger = yes
		has_religion = religion:zoroastrianism_religion
		any_in_global_list = {
			variable = unavailable_unique_decisions
			this = flag:flag_became_saoshyant
		}
		NOT = {
			primary_title = {
				has_title_law = mahestan_elective_succession_law
			}
		}
		any_held_title = {
			NOR = {
				has_title_law = gaelic_elective_succession_law
				has_title_law = imperial_elective_succession_law
				has_title_law = scandinavian_elective_succession_law
				has_title_law = eldership_elective_succession_law
				has_title_law = princely_elective_succession_law
				has_title_law = feudal_elective_succession_law
				has_title_law = outremer_elective_succession_law
				has_title_law = royal_elective_succession_law
				has_title_law = saxon_elective_succession_law
				has_title_law = kurultai_elective_succession_law
			}
		}
	}
	effect = {
		every_held_title = {
			limit = { has_title_law = mahestan_elective_succession_law }
			clear_title_laws = yes
		}
		primary_title = {
			add_title_law = mahestan_elective_succession_law
		}
	}
	ai_will_do = 100
}
kurultai_elective_ai = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	}
	ai_goal = yes
	is_shown = {
		is_ai = yes
	}
	is_valid = {
		is_ai = yes
		highest_held_title_tier >= tier_kingdom
		can_change_title_law_trigger = yes
		culture = {
			has_innovation = innovation_kurultai
			has_cultural_pillar = heritage_mongolic
		}
        government_has_flag = government_is_tribal
		NOT = {
			primary_title = {
				has_title_law = kurultai_elective_succession_law
			}
		}
		any_held_title = {
			NOR = {
				has_title_law = gaelic_elective_succession_law
				has_title_law = imperial_elective_succession_law
				has_title_law = scandinavian_elective_succession_law
				has_title_law = eldership_elective_succession_law
				has_title_law = princely_elective_succession_law
				has_title_law = feudal_elective_succession_law
				has_title_law = outremer_elective_succession_law
				has_title_law = royal_elective_succession_law
				has_title_law = saxon_elective_succession_law
				has_title_law = mahestan_elective_succession_law
			}
		}
	}
	effect = {
		every_held_title = {
			limit = { has_title_law = kurultai_elective_succession_law }
			clear_title_laws = yes
		}
		primary_title = {
			add_title_law = kurultai_elective_succession_law
		}
	}
	ai_will_do = 100
}
feudal_elective_diet = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	}
		
	decision_group_type = major
	ai_goal = yes
	is_shown = {
		character:90107 = {
			is_alive = no
		}
		primary_title = {
			OR = {
				this = title:k_bavaria
				this = title:k_east_francia
				this = title:k_lotharingia
				this = title:k_frisia
				this = title:k_france
				this = title:k_aquitaine
				this = title:k_alemania
			}
		}
		NOT = {
			AND = {
				title:k_bavaria.holder = title:k_east_francia.holder
				character:90107 = {
					any_child = {
						OR = {
							this = title:k_bavaria.holder
							this = title:k_east_francia.holder
						}
					}
				}
			}
			primary_title = {
				has_title_law = feudal_elective_succession_law
			}
		}
		OR = {
			has_game_rule = all_succexp_his_events
			AND = {
				has_game_rule = ai_succexp_his_events
				is_ai = yes
			}
		}
	}
	is_valid = {
		custom_description = {
			any_vassal = {
				is_powerful_vassal_of = root
				opinion = {
					target = root
					value < 0
				}
			}
			text = powerfull_vassl_has_neg_opin_loc
		}
		can_change_title_law_trigger = yes
		custom_description = {
			any_held_title = {
				NOR = {
					has_title_law = gaelic_elective_succession_law
					has_title_law = imperial_elective_succession_law
					has_title_law = scandinavian_elective_succession_law
					has_title_law = eldership_elective_succession_law
					has_title_law = princely_elective_succession_law
					has_title_law = feudal_elective_succession_law
					has_title_law = outremer_elective_succession_law
					has_title_law = mahestan_elective_succession_law
					has_title_law = royal_elective_succession_law
					has_title_law = kurultai_elective_succession_law
				}
			}
			text = no_special_succ_loc
		}
	}
	cost = {
		prestige = 1000
	}
	effect = {
		primary_title = {
			add_title_law = feudal_elective_succession_law
		}
		every_vassal = {
			limit = {
				is_powerful_vassal_of = root
			}
			add_opinion = {
				target = root
				modifier = favorable_succession
				opinion = 30
			}
		}
	}
	ai_will_do = 100
}